<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

use think\Route;
use \think\Request;

$request = Request::instance();

if (!file_exists(RUNTIME_PATH . '/install.lock') && $request->url() != '/install') {
    exit('请先安装<a href="/install" target="_black">/install</a>');
}

// 首页
Route::any('/', 'index/Index/index');

// 列表页
Route::any('list/<vt>/<year>/<area>/<cat>/<rank>/<page>', 'index/Index/list', ['ext' => "html|json"]);
Route::any('list/<vt>-<year>-<area>-<cat>-<rank>-<page>', 'index/Index/list', ['ext' => "html|json"]);

// 详情页
Route::any('detail-<vt>/<type>/<sign>', 'index/Index/detail', ['ext' => "html|json"]);

//播放页
// Route::any('play-/<vt>/<sign>', 'index/Index/play', ['ext' => "html|json"]);
Route::any('play-<vt>/<type>/<sign>', 'index/Index/play', ['ext' => "html|json"]);
// Route::any('play/<vt>/<sign>', 'index/Index/play', ['ext' => "html|json"]);

//搜索页
Route::any('search/index', 'index/Index/search', ['ext' => "html|json"],  ['wd' => '\w+']);

//加载
Route::any('jzad', 'index/Index/jzad');

#一键安装###########################################
Route::get('install', 'install/Index/index');
Route::post('install', 'install/Index/import');



#用户中心###########################################
// 用户页面
Route::any('user/:IndexPage', 'user/Index/inlet');
//初始用户化入口
Route::get('user', function () {
    $url = request()->domain();
    header("Location: " . $url . "/user/index");
});

// 用户动作
Route::any('v1/user/action/system/:IndexPage', 'user/System/inlet');



Route::any('cscs', function () {
    //curl的百度百科
    $url = 'http://www.baidu.com/link?url=77I2GJqjJ4zBBpC8yDF8xDhiqDSn1JZjFWsHhEoSNd85PkV8Xil-rckpQ8_kjGKNNq';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    // 不需要页面内容
    curl_setopt($ch, CURLOPT_NOBODY, 1);
    // 不直接输出
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    // 返回最后的Location
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_exec($ch);
    $info = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
    curl_close($ch);
    echo '真实url为：' . $info;
});





#后台相关###########################################


//获取后台入口地址
$adminPath = config('adminPath');

//后台页面入口
Route::get($adminPath . '/:Indexpage/', 'admin/Index/page');

//初始后台化入口
Route::get($adminPath, function () {
    $url = request()->domain();
    header("Location: " . $url . "/admin/index#/");
});

//页面数据接口
Route::any('v1/admin/data/:Indexpage', 'admin/Index/pagedata');

#后台数据提交接口#################################################

//后台登录
Route::any('ask/action/login', 'admin/Login/login');

// 通用添加
Route::any('ask/action/system/:Indexpage/add', 'admin/System/add');

// 通用修改
Route::any('ask/action/system/:Indexpage/edit', 'admin/System/edit');

// 通用删除
Route::any('ask/action/system/:Indexpage/del', 'admin/System/del');

//系统设置
Route::any('ask/action/system/:Indexpage', 'admin/System/system');

//模板LOGO上传
Route::post('ask/action/up/uplogo', 'admin/Upload/upImgLoad');

//清除数据缓存
Route::any('ask/action/zeroing', 'admin/System/zeroing');

//获取采集方法
Route::post('ask/action/collectionmethod', 'admin/System/collectionmethod');

// 扩展安装 
Route::post('action/system/install', 'admin/Install/init');
// 公告
Route::any('action/system/notice', 'admin/Install/notice');

return;
